<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>

        // 键盘事件
        //    keydown 键盘按下   持续触发
        //    keyup  键盘抬起

        //   keypress  几乎和keydown一样   部分功能键没有作用


        document.onkeydown = function () {
            console.log('键盘按下');
        }

        document.onkeyup = function () {
            console.log('键盘up');
        }

        document.onkeypress = function () {
            console.log('onkeypress');
        }

    </script>

</body>

</html>